﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace Cocon90.Lib.Web
{
    /// <summary>
    /// 与Session相关的权限辅助类
    /// </summary>
    public class permissionHelper : System.Web.SessionState.IRequiresSessionState
    {
        static string userSessionKey = "userSessionKey";
        /// <summary>
        /// 存放UserSession在Session中的键，默认是：userSessionKey
        /// </summary>
        public static string UserSessionKey { get { return userSessionKey; } set { userSessionKey = value; } }

        /// <summary>
        /// 获取 用户是否已登陆
        /// </summary>
        public static bool HasLogined
        {
            get
            {
                if (UserSession != null && (UserSession + "").Trim() != "")
                {
                    return true;
                }
                return false;
            }
        }
        /// <summary>
        /// 获取或设置 登录时存放的信息  ，如果未登陆，则返回""(空字符串)
        /// </summary>
        public static object UserSession
        {
            get
            {
                return HttpContext.Current.Session[UserSessionKey];
            }
            set
            {
                HttpContext.Current.Session[UserSessionKey] = value;
                HttpContext.Current.Session.Timeout = 60;
            }
        }

    }
}
